Documentation for Python's standard profilers can be found here: https://docs.python.org/3.5/library/profile.html
To then explore the output of the profiler use pstats
as so:
python -m pstats yourscript.profile
Useful pstats commands are:
help
- to get helpstrip
- to strip paths from filenamessort <key>
- to sort the results by the keystats <n>
- to show the top n resultscallers <pattern>
- to show what called the pattern (where pattern could be a function name)quit
- to quit pstatsA typical first step would be to strip paths from filenames:
strip
then sort by time:
sort time
and then see which functions are the top 10 by time spent:
stats 10
In [ ]:
https://github.com/jrfonseca/gprof2dot
You will need Graphviz:
Windows users can install graphviz as follows
In [ ]:
In [ ]:
In [ ]:
Writing faster Python: https://www.youtube.com/watch?v=YjHsOrOOSuI